﻿@model BudgetMealsUI.Models.ListViewModel<BudgetMealsModels.Entities.User>

@{
    ViewBag.Title = "Index";
}

<h2>User List</h2>
@Html.ActionLink("Create New...", "Create")
@if (Model.PageItems.Count() > 0)
{
    <table>
    <tr><th>Username</th><th>Real Name</th></tr>
@foreach (var m in Model.PageItems)
{
    <tr>
        <td>@Html.ActionLink(m.UserName, "Edit", new { id = m.UserID })</td>
        <td>@m.FirstName @m.LastName</td>
        <td>
            @using (@Html.BeginForm("Profile", "User"))
            {
                @Html.Hidden("id", m.UserID)
                <input type="submit" value="View Profile" />
            }
        </td>
        <td>
            @using (@Html.BeginForm("Delete", "User"))
            {
                @Html.Hidden("id", m.UserID)
                <input type="submit" value="Delete" />
            }
        </td>
    </tr>
    
}
</table>
<div class="pager">
    @Html.PageLinks(Model.Info, x => Url.Action("Index", new { page = x }))
</div>
}
else
{
    <p>There are no users.</p>
}